﻿
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>XXX网络商城</title>
		<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" />
		<script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js" type="text/javascript"></script>
		<script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script>

		<script>
			//页面加载成功之后 获取 热门商品信息  拼装到 页面上
			$(function () {
				setHotProducts();
			})

			function setHotProducts() {
				//1.url
				let url = "${pageContext.request.contextPath}/productServlet"
				//2.params
				let params={
					"method":"findHotProducts"
				}
				//3.callback
				let callback=function (rel) {
					//console.log(rel)
					// 拼装
					$(rel).each(function (index,ele) {

						$("#hotProductsDIV").append("<div class=\"col-md-2\" style=\"text-align:center;height:200px;padding:10px 0px;\">\n" +
								"\t\t\t\t\t\t<a href=\"product_info.htm\">\n" +
								"\t\t\t\t\t\t\t<img src=\"${pageContext.request.contextPath}/"+ele.pimage+"\" " +
								"width=\"130\" height=\"130\" style=\"display: inline-block;\">\n" +
								"\t\t\t\t\t\t</a>\n" +
								"\t\t\t\t\t\t<p><a href=\"product_info.html\" style='color:#666'>"+ele.pname+"</a></p>\n" +
								"\t\t\t\t\t\t<p><font color=\"#E4393C\" style=\"font-size:16px\">&yen;"+ele.shopPrice+"</font></p>\n" +
								"\t\t\t\t\t</div>")



					})

					// 发射ajax请求 获取最新商品
					setNewProducts();
				}
				//4.发射
				$.post(url,params,callback,"json")
			}



			function setNewProducts() {

				//1.url
				let  url = "${pageContext.request.contextPath}/productServlet"
				//2.params
				let params={
					"method":"findNewProducts"
				}
				//3.callback
				let callback=function (rel) {
					console.log(rel)
					$(rel).each(function (index,ele) {
						$("#newProductDIV").append("<div class=\"col-md-2\" style=\"text-align:center;height:200px;padding:10px 0px;\">\n" +
								"\t\t\t\t\t\t<a href=\"product_info.htm\">\n" +
								"\t\t\t\t\t\t\t<img src=\"${pageContext.request.contextPath}/"+ele.pimage+"\" width=\"130\" height=\"130\" style=\"display: inline-block;\">\n" +
								"\t\t\t\t\t\t</a>\n" +
								"\t\t\t\t\t\t<p><a href=\"product_info.html\" style='color:#666'>"+ele.pname+"</a></p>\n" +
								"\t\t\t\t\t\t<p><font color=\"#E4393C\" style=\"font-size:16px\">&yen;"+ele.shopPrice+"</font></p>\n" +
								"\t\t\t\t\t</div>\n" +
								"\t")
					})
				}
				//4.发射
				$.post(url,params,callback,"json")

			}
		</script>




	</head>

	<body>
		<div class="container-fluid">


			<%@ include file="header.jsp"%>

			<!--
            	描述：轮播条
            -->
			<div class="container-fluid">
				<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
					<!-- Indicators -->
					<ol class="carousel-indicators">
						<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
						<li data-target="#carousel-example-generic" data-slide-to="1"></li>
						<li data-target="#carousel-example-generic" data-slide-to="2"></li>
					</ol>

					<!-- Wrapper for slides -->
					<div class="carousel-inner" role="listbox">
						<div class="item active">
							<img src="${pageContext.request.contextPath}/img/ad/1.jpg">
							<div class="carousel-caption">

							</div>
						</div>
						<div class="item">
							<img src="${pageContext.request.contextPath}/img/ad/2.jpg">
							<div class="carousel-caption">

							</div>
						</div>
						<div class="item">
							<img src="${pageContext.request.contextPath}/img/ad/3.jpg">
							<div class="carousel-caption">

							</div>
						</div>
					</div>

					<!-- Controls -->
					<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
						<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
						<span class="sr-only">Previous</span>
					</a>
					<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
						<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
						<span class="sr-only">Next</span>
					</a>
				</div>
			</div>
			<!--

            	描述：商品显示
            -->
			<div class="container-fluid">
				<div class="col-md-12">
					<h2>热门商品&nbsp;&nbsp;<img src="${pageContext.request.contextPath}/img/title2.jpg"/></h2>
				</div>
				<div class="col-md-2" style="border:1px solid #E7E7E7;border-right:0;padding:0;">
					<img src="${pageContext.request.contextPath}/products/hao/big01.jpg" width="205" height="404" style="display: inline-block;"/>
				</div>
				<div class="col-md-10" id="hotProductsDIV">
					<div class="col-md-6" style="text-align:center;height:200px;padding:0px;">
						<a href="product_info.htm">
							<img src="${pageContext.request.contextPath}/products/hao/middle01.jpg" width="516px" height="200px" style="display: inline-block;">
						</a>
					</div>
				
<%--					<div class="col-md-2" style="text-align:center;height:200px;padding:10px 0px;">--%>
<%--						<a href="product_info.htm">--%>
<%--							<img src="${pageContext.request.contextPath}/products/hao/small03.jpg" width="130" height="130" style="display: inline-block;">--%>
<%--						</a>--%>
<%--						<p><a href="product_info.html" style='color:#666'>冬瓜</a></p>--%>
<%--						<p><font color="#E4393C" style="font-size:16px">&yen;299.00</font></p>--%>
<%--					</div>--%>
	

				</div>
			</div>
			<!--

            	描述：广告部分
            -->
            <div class="container-fluid">
				<img src="${pageContext.request.contextPath}/products/hao/ad.jpg" width="100%"/>
			</div>
			<!--

            	描述：商品显示
            -->
			<div class="container-fluid">
				<div class="col-md-12">
					<h2>最新商品&nbsp;&nbsp;<img src="${pageContext.request.contextPath}/img/title2.jpg"/></h2>
				</div>
				<div class="col-md-2" style="border:1px solid #E7E7E7;border-right:0;padding:0;">
					<img src="${pageContext.request.contextPath}/products/hao/big01.jpg" width="205" height="404" style="display: inline-block;"/>
				</div>
				<div class="col-md-10" id="newProductDIV">
					<div class="col-md-6" style="text-align:center;height:200px;padding:0px;">
						<a href="product_info.htm">
							<img src="${pageContext.request.contextPath}/products/hao/middle01.jpg" width="516px" height="200px" style="display: inline-block;">
						</a>
					</div>
				


				</div>
			</div>			
			<!--
            	描述：页脚部分
            -->
			<div class="container-fluid">
				<div style="margin-top:50px;">
					<img src="${pageContext.request.contextPath}/img/footer.jpg" width="100%" height="78" alt="我们的优势" title="我们的优势" />
				</div>
		
				<div style="text-align: center;margin-top: 5px;">
					<ul class="list-inline">
						<li><a href="${pageContext.request.contextPath}/jsp/info.jsp">关于我们</a></li>
						<li><a>联系我们</a></li>
						<li><a>招贤纳士</a></li>
						<li><a>法律声明</a></li>
						<li><a>友情链接</a></li>
						<li><a>支付方式</a></li>
						<li><a>配送方式</a></li>
						<li><a>服务声明</a></li>
						<li><a>广告声明</a></li>
					</ul>
				</div>
				<div style="text-align: center;margin-top: 5px;margin-bottom:20px;">
					Copyright &copy; 2005-2016 传智商城 版权所有
				</div>
			</div>
		</div>
	</body>

</html>